
$(function(){
    //top.Dialog.close();
});


$.quiDefaults.Grid.formatters['date'] = function (value, column) {
	return dateFormat.format(new Date(value), DateFormat.DEFAULT_DATETIME_FORMAT);
}

var listObj = new Object;

function reflushList(){
	getData2(listObj.url, listObj.data);
}

function getData(url, data, pageNo, pageSize){
	listObj.url = url;
	listObj.data = data;
	$.post(url,
			data,
			function(result){
		//console.log(result);
				$("#pageContent").html('');
				gridData = result;
				gridData.rows = result.result;
				//alert(g);
				//刷新表格
				g.loadData(gridData);
				getPage(gridData);
			},"json");
}

function getData2(url, data){
	$.post(url,
			data,
			function(result){
				gridData = result;
				gridData.rows = result.result;
				//刷新表格
				g.loadData(gridData);
				getPage(gridData);
			},"json");
}

function getPage(gridData){
	$("#pageContent").html('');
	var $pager=$('<div id="pageI" class="pageArrow float_right padding5" showSelect="true" showNumber="true" inputPosition="right"></div>');
	$pager.attr("total",gridData.totalCount);
	$pager.attr("pageSize",gridData.pageSize);
	$pager.attr("selectData",'{"list":[{"key":20,"value":20},{"key":50,"value":50},{"key":100,"value":100}]}');
	
	var $pagerCon = $('<div class="float_left padding5">' + "共有" + gridData.totalCount + "条记录" + '</div><div class="float_right padding5"></div><div class="clear"></div>');
	$pagerCon.eq(1).append($pager);
	$("#pageContent").append($pagerCon);
	$pager.render();
	$pager.bind("pageChange",function(e,index){
		data.currPage = index+1;
		listObj.data = data;
		getData2(url, data);           
	});
	
	$pager.bind("sizeChange",function(e,num){
		data.pageSize = num;
		listObj.data = data;
		getData2(url, data);
	});
}

